package com.twentytwok.hospitalsystem22K.controller;


import com.twentytwok.hospitalsystem22K.common.PageVo;
import com.twentytwok.hospitalsystem22K.common.R;
import com.twentytwok.hospitalsystem22K.pojo.News;
import com.twentytwok.hospitalsystem22K.service.NewsService;
import com.twentytwok.hospitalsystem22K.util.QiNiuUtils;
import com.twentytwok.hospitalsystem22K.vo.NewsQueryVo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;


/**
 * 新闻管理模块控制层
 *
 * @author 鑫小小
 * @data 2021年11月11日10:08:33
 */

@RestController
@RequestMapping("/api/news")
@CrossOrigin("*")
public class NewsController {

    @Resource
    private NewsService newsService;

    @RequestMapping("/listNews")
    public List<News> findNews() {
        return newsService.findNews();
    }

    @RequestMapping("/pageDataNews")
    public R getDataNews(NewsQueryVo newsQueryVo) {
        return newsService.getDataNews(newsQueryVo);
    }

    @RequestMapping("/listNewsByTime")
    public R listNewsByTime(NewsQueryVo newsQueryVo) {
        return newsService.listNewsByTime(newsQueryVo);
    }

    @RequestMapping("/addNews")
    public R addNews(News news) {
        return newsService.addNews(news);
    }

    @RequestMapping("/deleteNews")
    public R deleteNews(Integer id) {
        return newsService.deleteNews(id);
    }

    @RequestMapping("/modifyNews")
    public R modifyNews(News news) {
        return newsService.modifyNews(news);
    }


    @RequestMapping("/getNewsById")
    public R getNewsById(Integer id) {
        return newsService.getNewsById(id);
    }

   @RequestMapping("newsPie")
    public R getNewsAsPie(){
        return newsService.getNewsAsPie();
   }
}
